<?php
class SuggestAction extends Action {
	public function insert(){
		$Form = D('Suggest');
		if($Form->create()){
			$result = $Form->add();
			if($result){
				$this->success('操作成功!');
				
			}else{
				$this->error('写入错误!');
			}
		}else{
			$this->error($Form->getError());
		}
	}
	
	public function read($id=0){
		$Form   =   M('Suggest');
		// 读取数据
		$data =   $Form->find($id);
		if($data) {
			$this->data =   $data;// 模板变量赋值
		}else{
			$this->error('数据错误');
		}
		$this->display();
	}

	public function edit($id=0){
		$Form = M('Suggest');
		$this->vo = $Form ->find($id);
		$this->display();
	}
	public function update(){
		$Form = D('Suggest');
		if($Form->create()){
			$result= $Form->save();
			if($result){
				$this->success('操作成功!');
			}else{
				$this->error('写入错误!');
			}
		}else{
			$this->error($Form->getError());
		}
	}
	public function delete($id=0){
		$Form = M("Suggest");
		$result = $Form ->delete($id);
		if($result==0){
			$this->error('没有数据被删除');
		}elseif($result==false){
			$this->error('SQL Error');
		}else{
			$this->success($result.'删除成功!');
		}

	}
}